﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text;

namespace BusinessLogic
{
    public class CalculateSumCommand : BaseCommand<object>
    {

        public CalculateSumCommand(int SaleCampaignId, int DeliveryCampaignId, int GotSpecial, int HasSpecial)
        {
            SetQuery("EXEC ACM_CAL_SUM @saleCampaignId,@deliveryCampaignId,@gotSpecial,@hasSpecial");

            cmd.Parameters.AddWithValue("saleCampaignId", SaleCampaignId);
            cmd.Parameters.AddWithValue("deliveryCampaignId", DeliveryCampaignId);
            cmd.Parameters.AddWithValue("gotSpecial", GotSpecial);
            cmd.Parameters.AddWithValue("hasSpecial", HasSpecial);
        }

        public override void Command()
        {
            SqlDataReader dr = cmd.ExecuteReader();

            if (dr.HasRows)
            {
                dr.Read();
                Result = dr.GetDecimal(0);
            }
            else
                Result = 0;
        }

    }
}
